package com.example.demo.mapper;

import com.example.demo.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    //查询所有学生信息
    @Results(id="studentResult",value={
            @Result(property="id",column = "id"),
            @Result(property="name",column = "name"),
            @Result(property="age",column = "age"),
            @Result(property="sex",column = "sex")
    })

    @Select("select * from yue")
    List<Student> getAll();

    //根据学号查询学生信息
    @ResultMap("studentResult")
    @Select("select * from yue where id=#{id}")
    Student getStudentByNumber(Integer id);

    //添加学生信息
    @Insert("insert into yue (id,name,sex,age) values (#{id},#{name},#{sex},#{age})")
    int addStudent(Student student);
}
